import { defineStore } from 'pinia'
import { ref } from 'vue'
import zhCN from 'ant-design-vue/es/locale/zh_CN'

export const useLayoutStore = defineStore(
  'layout',
  () => {
    // 侧边栏状态
    const sidebarState = ref({
      // 侧边栏折叠
      collapsed: false,
      // 主题颜色 light | dark
      theme: 'light',
      collapsedWidth: '80',
      // 选中的菜单key
      selectedKeys: ['/'],
      openKeys: [''],
      trigger: false,
      locale: zhCN
    })

    function collapse() {
      sidebarState.value.collapsed = !sidebarState.value.collapsed
    }

    return { sidebarState }
  },
  {
    persist: true
  }
)
